package com.xjm.dataservice.controller;

import com.xjm.dataservice.entity.Product;
import com.xjm.dataservice.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RefreshScope
public class ProductController {
  
    @Autowired
    private ProductService productService;

    @Value("${version}")
    String version;
     
    @RequestMapping("/products")
    public Object products() {
        List<Product> ps = productService.listProducts();
        Product product = new Product();
        product.setName(version);
        ps.add(product);
        return ps;
    }
}